package com.dy.drp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dy.drp.entity.Cargo;
import com.dy.drp.mapper.CargoMapper;
import com.dy.drp.service.ICargoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dy
 * @since 2022-04-02
 */
@Service
public class CargoServiceImpl extends ServiceImpl<CargoMapper, Cargo> implements ICargoService {
    @Autowired
    private CargoMapper cargoMapper;

    @Override
    public boolean insertOne(Cargo cargo) {
        return cargoMapper.insertOne(cargo) > 0 ? true : false;
    }

    @Override
    public Cargo getOneBuyNameAndFactory(String cargoName, String cargoFactory) {
        QueryWrapper<Cargo> wrapper = new QueryWrapper<>();
        wrapper.eq("cargo_name",cargoName);
        wrapper.eq("cargo_factory",cargoFactory);
        return cargoMapper.selectOne(wrapper);
    }
}
